package com.xinhua.erp.controller;

import com.xinhua.erp.pojo.ProcessBom;
import com.xinhua.erp.pojo.Result;
import com.xinhua.erp.service.ProcessBomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("processBom")
public class ProcessBomController {

    @Autowired
    private ProcessBomService processBomService;

    @GetMapping("{id}")
    public Result findById(@PathVariable long id){

        return processBomService.findById(id);

    }

    @GetMapping("{page}/{size}")
    public Result findAll(@PathVariable int page,@PathVariable int size){

        return processBomService.findAll(page,size);

    }

    @GetMapping
    public Result findAllBom(){
        return processBomService.findAllBom();
    }

    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable long id){

        return processBomService.deleteById(id);

    }

    @PostMapping
    public Result save(@RequestBody ProcessBom processBom){

        return processBomService.save(processBom);

    }

    @PutMapping("{id}")
    public Result update(@RequestBody ProcessBom processBom,@PathVariable Long id){

        return processBomService.update(processBom,id);

    }

    @PostMapping("search/{page}/{size}")
    public Result Search(@RequestBody Map searchMap, @PathVariable int page, @PathVariable int size){

        return processBomService.Search(searchMap, page, size);

    }

}
